<!-- Author:Rain -->
<template>
  <!-- 实现一个导航栏,包括面试经验,AI模拟面试两部分,不使用element-ui -->
  <div class="interview">
    <section>
      <div class="nav">
        <router-link
          to="/geek/interview/interviewExperience"
          :class="{ active: active === 0 }"
          @click="activeChange(0)"
          >面试经验</router-link
        >
        <router-link
          to="/geek/interview/aiInterview"
          :class="{ active: active === 1 }"
          @click="activeChange(1)"
          class="useAI"
          >AI模拟面试
          <div class="num">免费{{ virtualInterviewTimes }}次<i class="white-line"></i></div
        ></router-link>
      </div>
      <router-view name="interviewExperience"></router-view>
      <router-view name="aiInterview"></router-view>
    </section>
    <aside>
      <router-view name="experienceRelease"></router-view>
      <router-view name="experienceShare"></router-view>
    </aside>
  </div>
</template>

<script setup lang="ts">
import { useUserStore } from '@/store/modules/user'
const userStore = useUserStore()
const { virtualInterviewTimes } = toRefs(userStore)
const active = ref(+window.localStorage.getItem('active') || 0)
function activeChange(index: number) {
  active.value = index
  window.localStorage.setItem('active', index)
}
</script>

<style scoped>
.interview {
  display: flex;
  justify-content: space-between;
  width: 1184px;
  margin: 0 auto;
  padding-top: 20px;
  background-color: transparent;
  height: var(--windowHeight);
  overflow: auto;
  background-color: #f5f5f5;
}

.interview::after {
  content: '';
  display: block;
  position: absolute;
  background-color: var(--childThemeColor);
  inset: 0;
  z-index: -1;
}

section {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
  padding: 20px;
  border-radius: 12px;
}

.interview section .nav {
  display: flex;
  background-color: #fff;
  border-radius: 12px;
  padding: 20px 10px;
  font-size: 16px;
  justify-content: space-around;
  margin-bottom: 20px;
  box-shadow: var(--boxShadow);
}

aside {
  top: 0px;
  position: relative;
  overflow: hidden;
  /* width: 200px; */
  /* height: 200px; */
  padding: 20px;

  margin-left: 20px;
}

.interview .active {
  position: relative;
  font-weight: bold;
  color: var(--childThemeColor);
}

.interview .active::after {
  content: '';
  display: block;
  width: 50px;
  height: 8px;
  border-radius: 4px;
  inset: auto;
  position: absolute;

  background: linear-gradient(90deg, #07c4f8 0%, #77fae6 50%, #07c4f8 100%);
}

.useAI {
  position: relative;
}

.num {
  position: absolute;
  font-family: PingFangSC-Regular, sans-serif;
  right: -47px;
  top: -20px;
  color: #fff;
  background: url(../../../assets/icons/tip3.svg) no-repeat;
  background-size: 50%;
  background-position: center;
  border-radius: 15px;
  text-align: center;
  line-height: 20px;
  width: 80px;
  height: 20px;
  padding: 6px 12px;
  font-size: 12px;
}

.white-line {
  animation: light-done 1s linear 0s infinite running;
  background: linear-gradient(90deg, hsla(0, 0%, 100%, 0.7), hsla(0, 0%, 100%, 0));
  bottom: 10px;
  left: 0;
  position: absolute;
  top: 8px;
  transform: rotate(225deg);
  width: 10%;
}

@keyframes light-done {
  0% {
    left: 0;
  }
  100% {
    left: 100%;
  }
}
</style>
